﻿/* 
 * Copyright 2010 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace Ngilead.Core.Replicator
{
    /// <summary>
    /// Bean transformer contract
    /// </summary>
    public interface IBeanTransformer
    {
        /// <summary>
        /// Used to initialize the replicator factory for collections.
        /// </summary>
        CollectionReplicator CollectionReplicator { get; set; }

        /// <summary>
        /// Used to initialize the replicator factory for maps.
        /// </summary>
        DictionaryReplicator DictionaryReplicator { get; set; }

        /// <summary>
        /// Used to initialize the replicator factory for arrays.
        /// </summary>
        InstanceReplicator InstanceReplicator { get; set; }       
        
        /// <summary>
        /// Sets the property filter.
        /// </summary>
        IPropertyFilter PropertyFilter { get; set; }

        /// <summary>
        /// Call the property filter (if defined) to indicate if the property must be cloned or not
        /// </summary>
        /// <param name="propertyName">Property name</param>
        /// <param name="fromBean">Object from</param>
        /// <param name="toBean">Object to</param>
        /// <returns>true/false</returns>
        bool ShouldPopulate(string propertyName, object fromBean, object toBean);

        /// <summary>
        /// Get the cloned map
        /// </summary>
        /// <returns></returns>
        Dictionary<object,object> GetClonedMap();

        /// <summary>
        /// Recursive clone of argument
        /// </summary>
        /// <param name="from"></param>
        T Replicate<T>(T from);

       /// <summary>
        /// Gets the parent of the current cloned bean
        /// </summary>
        /// <returns></returns>
        object GetCurrentParent();
        
        /// <summary>
        /// Property for current proxy informations
        /// (needed for merge operation)
        /// </summary>
        Dictionary<string, object> CurrentProxyInformations { get; set; }
    }
}
